package map;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MainClassArrayList {
	public static List<String> list = new ArrayList<String>();

	public static void main(String[] args) throws InterruptedException {
		list = Collections.synchronizedList(list);
		Thread t1 = new Thread() {
			public void run() {
				for (int i = 0; i < 25; i++) {
					list.add(String.valueOf(i));
				}
			}
		};

		Thread t2 = new Thread() {
			public void run() {
				for (int j = 25; j < 50; j++) {
					list.add(String.valueOf(j));
				}
			}
		};

		t1.start();
		t2.start();

		Thread.sleep(1000);

		for (int i = 0; i < 50; i++) {
			System.err.println(i + ":" + list.get(i));
		}
	}
}
